package entities.axiom;

import java.util.HashSet;

import option.KBVocabulary;

import utils.Display;

import entities.concept.Concept;
import entities.concept.NotConcept;
import entities.concept.OrConcept;

public class InclusionAxiom extends ConceptAxiom {

	public InclusionAxiom(Concept lhs, Concept rhs) {
		super(lhs, rhs);
	}

	// for a->b, get ~a or b. if a is top, just b, if a is bot, returns top.
	public Concept toConcept() {
		Concept ret = null;
		if (this.getLHS().isTop()) {
			ret = this.getRHS();
		} else if (this.getLHS().isBot()) {
			ret = option.KBVocabulary.CONCEPT_TOP;
		} else {
			// return ~a or b
			HashSet<Concept> ors = new HashSet<Concept>();
			ors.add(this.getRHS());
			ors.add(new NotConcept(this.getLHS()));
			ret = new OrConcept(ors);
		}
		return ret;
	}

	@Override
	public String toString() {
		return this.getLHS() + " " + Display.IMPLIESUNICODE + " "
				+ this.getRHS();
	}

	public String toSerializedString() {
		return " (" + KBVocabulary.IMPLIES + " "
				+ this.getLHS().toSerializedString() + " "
				+ this.getRHS().toSerializedString() + ") ";
	}

}